package com.gaocf.designpatterns.behavior.strategy;

/**
 * @author gaocf
 * 策略设计模式
 */
public class CashContext {
    private Cash cash;

    public CashContext(int type) {
        switch (type) {
            case 1:
                cash = new NormalCash();
                break;
            case 2:
                cash = new DiscountCash(0.85);
                break;
            case 3:
                cash = new RebateCash("300", "100");
                break;
        }
    }

    public double getRealMoney(double money) {
        return cash.calculateRealCash(money);
    }
}
